package com.android.lovingpet.mine.setting.accountsecurity;

import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.lovingpet.R;
import com.android.lovingpet.base.BaseFragment;

public class IdCardFragment extends BaseFragment<IAuthContract.View, AuthPresenter> implements View.OnClickListener, IAuthContract.View {

    private LinearLayout llIdCard;
    private EditText etName;
    private EditText etIdCard;
    private TextView tvGone;
    private IAuthContract.Presenter presenter;

    @Override
    protected int setContentView() {
        return R.layout.fragment_idcard;
    }

    @Override
    protected void onCreateView(View view) {
        llIdCard = view.findViewById(R.id.ll_idCard);
        etName = view.findViewById(R.id.et_name);
        etIdCard = view.findViewById(R.id.et_idCard);
        tvGone = view.findViewById(R.id.tv_gone);
        presenter = getPresenter();
        view.findViewById(R.id.bt_send).setOnClickListener(this);
        ((TextView) view.findViewById(R.id.tv_title)).setText("身份认证");
    }

    @Override
    public AuthPresenter createPresenter() {
        return new AuthPresenter(this);
    }

    @Override
    public IAuthContract.View createView() {
        return this;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_send:
                presenter.authIdCard(etName.getText().toString().trim(),
                        etIdCard.getText().toString().trim());
                break;

            default:
                break;
        }
    }

    @Override
    public void setView() {
        getActivity().runOnUiThread(() -> {
            llIdCard.setVisibility(View.GONE);
            tvGone.setText("已发送验证信息");
            tvGone.setVisibility(View.VISIBLE);
        });
    }
}
